Graphs of derivatives
First Book

This Mathematica notebook is licensed under a MouseOver .

This  notebook contains some of the code used to create the MouseOver on abstractmath.org.

GT := 3

Introduction

This file provides graphs showing some of the derivatives of many functions you may meet in learning college math.  If you own Mathematica 10, you can experiment with this file by modifying it and adding other functions.  If you don' t own Mathematica 10 but you own MouseOver (which can be downloaded for free) you can still read it and operate the manipulable graphs.

There is also a Second Book which will appear soon, and eventually a Third Book which will appear when I get around to it.

Hyperlink["CDF Reader","https://www.wolfram.com/cdf-player/"]

Definition of Derivative

A real valued function f may have a derivative, which is another real valued function denoted by f'.  At a point a, f'[a] is the slope of the tangent line to the curve y = f[x] at the point (a, f[x]). This is a precise definition of the derivative of f, but doesn’t tell you how to calculate it.  That’s what you learn in first-semester calculus.

Functions used in creating the examples

ShowDerivatives[f_,n_,a_,b_] :=Plot[Take[{f[x],f'[x],f''[x],f'''[x],f''''[x]}, n] // Evaluate,{x,a,b}, Prolog->AbsoluteThickness[GT],PlotRange->{a,b}, AspectRatio->1, ImageSize -> {200,200},PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[.7,0,.7]}]

TO DO : Make SD print each line in the appropriate color.

TO DO : Increase the type size in the SD printout.  It is not obvious how to do this.

TO DO : Bring the graph of the function to the front so that the derivatives all pass underneath it.

SD[f_,n_,a_,b_, c_, d_, s_] := ((r := (d-c)/(b-a)); Plot[Take[{f[x],f'[x],f''[x],f'''[x],f''''[x],f'''''[x]}, n] // Evaluate,{x,a,b}, PlotRange->{c,d},Prolog->AbsoluteThickness[GT], AspectRatio->r, ImageSize -> { s,r s},PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[.7,0,.7],RGBColor[0,.7,.7]}])

The derivatives are shown in each graph by color.  
function: blue
first derivative : red
second : green
third : gold
fourth : purple
fifth: light blue

DF prints out the formulas for the derivatives

DF[f_,n_]:=
TraditionalForm[
TableForm[
Take[{{"function",f[x]},{"1st deriv",f'[x]},{"2nd deriv",f''[x]},{"3rd deriv",f'''[x]},{"4th deriv",f''''[x]},{"5th deriv",f''''[x]},{"6th deriv",f''''[x]}}, n]]]

Constant function

const[x_] := 1

The tangent line to the straight line y = 1 is itself.

const'[x]

The derivative is the constant 0 because the straight line y = 1 has slope 0. You need to know only the definition of derivative to know that. You don' t need to know any "formula".

ShowDerivatives[const,2,-2,2]

Straight lines

identity function

id[x_] := x

The identity function has slope = 1 everywhere

ShowDerivatives[id,3,-2,2]

(*{{a,0.7},-2,2,.001,Appearance->"Open"},{{b,1.2},-2,2,.001,Appearance->"Open"},SaveDefinitions->True]*)

straight lines with various slopes

slslip[x_] := x-(1/4)

ShowDerivatives[slslip,3,-2,2]

sldown[x_] := -(5/4)x+1

ShowDerivatives[sldown,3,-2,3]

slhalf[x_] := 1/2 x

ShowDerivatives[slhalf,3,-2,2]

slhup[x_] := 1.5x-.5

ShowDerivatives[slhup,3,-2,2]

Manipulable diagram for straight lines

Changing the value of b does not change either the first or second derivative.

Manipulate[
ShowDerivatives[a * #+b& ,3,-2,2],{{a,1},-1.99,1.99,Appearance->"Open"},{{b,1},-1,1,Appearance->"Open"},
SaveDefinitions->True]

Absolute value

There is no tangent line at (0, 0) because the graph has a corner there.

leftd[x_] := 1 /; x > 0

rightd[x_] := -1 /; x < 0

Plot[{Abs[x],leftd[x], rightd[x]},{x,-3,3},PlotRange->{-3,3},AspectRatio->1,ImageSize->{200,200},Prolog->AbsoluteThickness[GT],PlotStyle->{{RGBColor[0,0,1]},{RGBColor[1,0,0]},{RGBColor[1,0,0]},RGBColor[.7,.7,0],RGBColor[0.7,0,.7]}]

Quadratic function

Remove[f,g,h]

q1[x_] := x^2

DF[q1,4]

SD[q1,4,-2,2,-3,3,150]

The following graph shows the same graph and two tangent lines (black)

g[x_] := x-(1/4)(*Tangent line at (-1,1) with slope -2*)

h[x_] := -2 x - 1(*Tangent line at (.5,.25) with slope -1*)

Plot[{q1[x],q1'[x],q1''[x],h[x],g[x]},{x,-4,4},PlotRange->{-4,4},AspectRatio->1,ImageSize->{300,300},Prolog->AbsoluteThickness[GT],PlotStyle->{{RGBColor[0,0,1]},{RGBColor[1,0,0]},{RGBColor[0,1,0]},RGBColor[0,0,0],RGBColor[0,0,0]}]

Manipulable the coefficients

TO DO : Show tangent lines as well

Manipulate[
SD[a * #^2 +b& ,3,-2,2,-3,3,150],{{a,1},-4,4,Appearance->"Open"},
{{b,0},-3,3,Appearance->"Open"},
SaveDefinitions->True]

Manipulate the roots

DF[(#-a)(#+b)&,3]

Manipulate[
SD[(#-a)(#-b)& ,3,-3,3,-9.3,8,100],{{a,-1},-3,3,Appearance->"Open"},
{{b,1},-3,3,Appearance->"Open"},
SaveDefinitions->True]

Cubics

First cubic function

This function has no local maxima or minima and one inflection point.

cu1[x_] := x^3

DF[cu1,5]

SD[cu1,3,-1.4,1.4,-2,2,200]

SD[cu1,4,-1.6,1.6,-1.5,6.5,150]

Second cubic function

This function has no maxima or minima or critical points. It has one inflection point. It has one real and two complex roots.

cu2[x_] := (x^3)+x

Factor[cu2[x]]//TraditionalForm

Solve[cu2[x]==0,x]

DF[cu2,3]

SD[cu2,3,-1.4,1.4,-2,3,200]

Third cubic function

This function has no maxima or minima or critical points. It has one inflection point. It has two real roots, one of multiplicity 2.

cu3[x_] := (x^3)+x^2

Factor[cu3[x]]//TraditionalForm

(∂_x)((x^2) (1+x))

Solve[cu3[x]==0,x]

DF[cu3,3]

SD[cu3,3,-1.4,1.4,-2,3,200]

Fourth cubic function

This function has local maxima and minima and three distinct real roots.

cu4[x_] := (x^3)-x

Factor[cu4[x]]//TraditionalForm

DF[cu4,3]//TeXForm

SD[cu4,3,-1.4,1.4,-2,1.5,200]

Fifth cubic function

This function has local maxima and minima and two real roots, one of multiplicity 2.

cu5[x_] := (x^3)-x^2

DF[cu5,4]

SD[cu5,3,-1.4,1.4,-2,1.5,200]

Sixth cubic function

This function has no local maxima or minima and three distinct roots, two of them complex.

cu6[x_] := (x^3)+x^2+x

Factor[cu6[x]]//TraditionalForm

Solve[cu6[x]==0,x]//N

DF[cu6,3]

SD[cu6,3,-1.4,1.4,-2,3,150]

Manipulable diagram of cubic functions

TO DO : This is not as general as it could be

cuall[a_,b_,x_]:=x^3+a x^2+b x

Manipulate[
SD[cuall[a,b,#]&,3,-2,2,-3,3,190],{{a,1},-4,4,Appearance->"Open"},
{{b,0},-3,3,Appearance->"Open"},
SaveDefinitions->True]

Quartics

First quartic function

quart1[x_] :=(1/4) (x^4)

quart1[.3]

I scaled it by 1/4 because it is hard to see the third derivative for f[x]:=x^4. This function has one quadruple zero at (0,0) and it is extremely flat there. Note that (.1)^4 is just .0001. Each of the three derivatives shown has just one zero, at 0, which makes it hard for the function to get off the ground near 0, so to speak.

DF[quart1,4]

SD[quart1,4,-1.4,1.4,-1.5,1.5,300]

Second quartic function

This function has two real roots.  It has to have at least two since it factors as x times a cubic, and a cubic always has a real root. You can see them in the answer to the Solve function below.

quart2[x_] := (1/4) ((x^4)-(x^2)+x)

quart2[x]

Factor[quart2[x]]

Solve[quart2[x]==0,x]//N

SD[quart2,4,-1.4,1.4,-1.5,1.5,300]

DF[quart2,4]

SD[quart2,4,-2,2,-2,3,300]

Third quartic function

Just like the second quartic function, this function has two real roots.  It has to have at least two since it factors as x times a cubic, and a cubic always has a real root. You can see them in the answer to the Solve function below.

quart3[x_] := (1/4) ((x^4)-(x^3)-x)

Factor[quart3[x]]

Solve[quart3[x]==0,x]//N

SD[quart3,4,-2,2,-2,3,300]

Fourth quartic function

quart4[x_] := (1/4)((x^4)-(x^3)+ (x^2)-x)

Factor[quart4[x]]

Solve[quart4[x]==0,x]

SD[quart4,4,-2,2,-2,3,300]

Fifth quartic function

This function has four real roots as you can see from the definition. The derivative has three real roots matching the three inflection points of the function.

quart5[x_] :=(1/4) (x (x+1) (x-1) (x-1.5))

DF[quart5,5]

SD[quart5,4,-2,2,-2,3,250]

Pochhammer

The  Pochhammer function of order n is x (x + 1) ... (x + n - 1), so Pochhammer[x, 4] is a quartic.

ph4[x_]:=Pochhammer[x,4]

DF[ph4,6]

SD[ph4,5,-4,1,-5.1,5,200]

quartall[a_,b_,c_,x_] := (1/4)((x^4)+a (x^3)+ b (x^2)+c x)

SD[quartall[1,1,1,#]&,4,-2,2,-3,3,300]

Manipulate[
SD[quartall[a,b,c,#]&,4,-2,2,-3,3,300],{{a,1},-2,2,Appearance->"Open"},
{{b,1},-3,3,Appearance->"Open"},
{{c,1},-3,3,Appearance->"Open"},
SaveDefinitions->True]

Quintic

I fiddled with this polynomial until I got the function and all four derivatives to be separated from each other.All the roots of the function and all its derivatives are real and all are shown. Isn' t this gorgeous?

quint[x_] := -.5 + .5x +.2 x^2 -.19 x^3 -.015x^4 + .01 x^5

DF[quint,5]

Solve[quint[x]==0,x]//N

Solve[quint'[x]==0,x]//N

Solve[quint''[x]==0,x]//N

Solve[quint'''[x]==0,x]//N

Solve[quint''''[x]==0,x]//N

SD[quint,5,-5,5,-5,5,300]

15/1000

15/1000//N

Rational functions

First rational function

This is the right half of a hyperbola that has a pole at x = 0.

rat1[x_] := 1/(x^2)

DF[rat1,6]

SD[rat1,6,0.01,4,-3,3,200]

Second rational function

The denominator is 0 at x = -1, so there is a pole there.  The asyptote is shown by a vertical green line

rat2[x_]:=(1/10)(x-1)/(x+1)

DF[rat2,5]

SD[rat2,4,-4,4,-5,5,300]

Third rational function

The denominator has no zeros so this is an entire function (which means it has no poles).

rat3[x_]:=(x-1)/(x^2+1)

DF[rat3,5]

SD[rat3,4,-4,4,-8,5,300]

Fourth rational function

rat4[x_] := (x^2-1)/(x^2+1)

DF[rat4,5]

The third derivative reaches up to about 9.3 and down to about - 9.5

SD[rat4,4,-3,3,-2,5,400]

Fifth rational function

rat5[x_] := (x^4)/((x^2+1)(x^2+2))

DF[rat5,6]

SD[rat5,4,-3,3,-2,2,400]

Functions involving  roots

Square root

DF[Sqrt,6]

SD[Sqrt,6,-4,4,-5,5,240]

Cube root

curt[x_]:=1/(x^(1.3))

DF[curt,6]

SD[curt,6,-4,4,-5,5,240]

Square root of (x^2)+1

sqxsq[x_]:=1/(Sqrt[x^2+1])

DF[sqxsq,6]

SD[sqxsq,4,-4,4,-2,2,400]